﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{

//Staghunt-Matrix                   | Dragonhut-Matrix                  | Skirmish-Matrix
//                                  |                                   |
//        Stag        Bunny         |           Fight         Rest      |               Sword       Magic       Alchemy
//                                  |                                   |
//Stag    2           -1            | Fight     2             1         | Sword         0           -1          1
//                                  |                                   |
//Bunny   1           0             | Rest      5             0         | Magic         1           0           -1
//                                  |                                   |
//                                  |                                   | Alchemy       -1          1           0

    class Agent
    {
        String[] skirmish = new String[]{"SWORD","MAGIC","ALCHEMY"};
        Minigame game;
        String decision;
        Boolean start = true;
        

        public Agent(String game)
        {
          
            if (game.Equals("STAGHUNT")) this.game = Minigame.STAGHUNT;
            else if (game.Equals("SKIRMISH")) this.game = Minigame.SKIRMISH;
            else if (game.Equals("DRAGON")) this.game = Minigame.DRAGONHUNT;
            else throw new Exception("Fehler: Minigame nicht gefunden");
        }

        public String play(int newScore)
        {
         

            if (game == Minigame.STAGHUNT)
            {
               return (playStaghunt(newScore));
            }
            else if (game == Minigame.DRAGONHUNT)
            {
               return (playDragonhunt(newScore));
            }
            else if (game == Minigame.SKIRMISH)
            {
                return (playSkirmish(newScore));
            }
            return null;
        }

        private String playStaghunt(int newScore)
        {


                //Zug: Ich - Stag, ?
                if (start)
                {
                    this.start = false;
                    decision = "STAG";
                }
                //Zug: Ich - Stag, Player2 - Stag
                else if (newScore == 2)
                {
                    decision = "STAG";
                }
                //Zug: Ich - Stag, Player2 - Bunny
                else if (newScore == - 1)
                {
                    decision = "BUNNY";
                }
                //Zug: Ich - Bunny, Player2 - Stag
                else if (newScore == 1)
                {
                    decision = "STAG";
                }              
                //Zug: Ich - Bunny, Player2 - Bunny
                else if (newScore == 0)
                {
                    decision = "BUNNY";
                }
                else
                    throw new Exception("Ungültiger Zug");

                
                decision = "ask:set:shunt:"+decision;
                return decision;
        }

        private String playDragonhunt(int newScore)
        {


     

                //Zug: Ich - Fight, ?
                if (start)
                {
                    this.start = false;
                    decision = "FIGHT";
                    
                }
                //Zug: Ich - Fight, Player2 - Fight
                else if (newScore == 2)
                {
                    decision = "FIGHT";
                }
                //Zug: Ich - Fight, Player2 - Rest
                else if (newScore == 1)
                {
                    decision = "REST";
                }
                //Zug: Ich - Rest, Player2 - Fight
                else if (newScore == 5)
                {
                    decision = "FIGHT";
                }
                //Zug: Ich - Rest, Player2 - Rest
                else if (newScore == 0)
                {
                    decision = "REST";
                }
                else
                    throw new Exception("Ungültiger Zug");


                decision = "ask:set:dragon:"+decision;
                return decision;
            
        }

        private String playSkirmish(int newScore)
        {

            Random random = new Random();
            int rdm = random.Next(0, 3);

            decision = "ask:set:skirm:" + skirmish[rdm];
            return decision;          
        }
    }



    enum Minigame
    {
        STAGHUNT,
        DRAGONHUNT,
        SKIRMISH
    }
}
